/* 
 * Copyright 2011 kOSMik.
 * This file is part of kOSMik.
 * 
 * kOSMik is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * kOSMik is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with kOSMik.  If not, see <http://www.gnu.org/licenses/>.
 *  
 * kOSMik:
 * Open Street Map - Editor.
 * http://code.google.com/p/swp-dv-ws2010-osm-2/
 */

package de.fuberlin.kosmik.data.dao;

import android.content.Context;
import android.os.Bundle;
import de.fuberlin.kosmik.data.DataBaseConnectorImpl;

/**
 * Object that represents a POI in the database schema.
 * 
 */
public class Poi extends Point {

	/**
	 * Internal ID of the POI.
	 */
	public long poiId;

	/**
	 * The attributes of this POI.
	 */
	public Bundle values;

	/**
	 * Constructor.
	 * 
	 * @param poiId data base id of the poi
	 * @param pointId data base id of the point
	 * @param lng longitude of point
	 * @param lat latitude of the point
	 * @param timestamp time the point was recorded
	 * @param values Bundle of the tags of the poi
	 */
	public Poi(long poiId, long pointId, double lng, double lat, long timestamp, Bundle values) {
		super(pointId, lng, lat, timestamp);
		this.poiId = poiId;
		this.values = values;
	}

	/**
	 * Adds a String value to the bundle of this poi.
	 * 
	 * @param k - key, under which the value should be saved
	 * @param string value to be put into the string, may be null.
	 */
	public void putValue(String k, String string) {
		values.putString(k, string);
	}

	/**
	 * Adds a boolean value to the bundle of this poi.
	 * 
	 * @param k - key, under which the value should be saved
	 * @param b - the boolean value
	 */
	public void putValue(String k, boolean b) {
		values.putBoolean(k, b);
	}

	/**
	 * Adds a long value to the bundle of this poi.
	 * 
	 * @param k - key, under which the value should be saved
	 * @param l - the long value
	 */
	public void putValue(String k, long l) {
		values.putLong(k, l);
	}

	/**
	 * Adds a String value to the bundle of this poi.
	 * 
	 * @param k - key, under which the value should be saved
	 * @param d - the double value
	 */
	public void putValue(String k, double d) {
		values.putDouble(k, d);
	}

	/**
	 * Overwrite the attributes of this POI.
	 * 
	 * @param b set a bundle to represent the tags of the poi
	 */
	public void setValues(Bundle b) {
		this.values = b;
	}

	/**
	 * 
	 * @return the attributes of this POI.
	 */
	public Bundle getValues() {
		return values;
	}

	/**
	 * 
	 * @return the id of the POI.
	 */
	public long getPoiId() {
		return poiId;
	}

	/**
	 * 
	 * @return the id of the point associated with this POI.
	 */
	public long getPointId() {
		return pointId;
	}

	/**
	 * The POI removes itself from the database.
	 * 
	 * @param context - the context of the calling instance
	 */
	public void remove(Context context) {
		new DataBaseConnectorImpl(context).removePoi(poiId);
	}

}
